home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 11 / Cream of the Crop 11-1.iso / games / ted5.zip / LIB_A.ASM < prev    next >
Assembly Source File  |  1993-02-04  |  3KB  |  260 lines

  1. ;====================================================
  2. ;
  3. ; Library ASM code
  4. ;
  5. ;====================================================
  6.     IDEAL
  7.     P386N
  8.     MODEL    medium,C
  9.  
  10. extrn    xormask:WORD,yshift:WORD,CGAfont:WORD,VGAfont:WORD
  11.  
  12.     DATASEG
  13.  
  14. SCindex    =    3c4h
  15. SCmapmask =    2
  16. GCindex =          3CEh
  17. GCreadmap =    4
  18. GCmode     =    5
  19.  
  20. a    =    0
  21. LABEL    CGAlookup WORD
  22. PUBLIC    CGAlookup
  23.     REPT    100
  24.     dw    a,a XOR 2000h
  25. a    =    a+80
  26.     ENDM
  27.  
  28. a    =    0
  29. LABEL    EGA1lookup WORD
  30. PUBLIC    EGA1lookup
  31.     REPT    200
  32.     dw    a
  33. a    =    a+40
  34.     ENDM
  35.  
  36. a    =    0
  37. LABEL    EGA2lookup WORD
  38. PUBLIC    EGA2lookup
  39.     REPT    480
  40.     dw    a
  41. a    =    a+80
  42.     ENDM
  43.  
  44. a    =    0
  45. LABEL    VGAlookup WORD
  46. PUBLIC    VGAlookup
  47.     REPT    200
  48.     dw    a
  49. a    =    a+320
  50.     ENDM
  51.  
  52.  
  53.     CODESEG
  54.  
  55. ;====================================================
  56. ;
  57. ; Draw CGA chars
  58. ;
  59. ;====================================================
  60. PROC CGAcharout
  61. PUBLIC CGAcharout
  62. ARG    x:WORD,y:WORD,chr:BYTE
  63. USES si,di,ds
  64.     mov    bx,[y]
  65.     shl    bx,1
  66.     shl    bx,1
  67.     shl    bx,1
  68.     shl    bx,1
  69.     mov    di,[CGAlookup+bx]
  70.     mov    ax,[x]
  71.     shl    ax,1
  72.     add    di,ax
  73.  
  74.     mov    al,[chr]
  75.     xor    ah,ah
  76.     shl    ax,1
  77.     shl    ax,1
  78.     shl    ax,1
  79.     shl    ax,1
  80.     mov    si,ax
  81.  
  82.     mov    ax,0b800h
  83.     mov    es,ax
  84.     mov    ds,[CGAfont]
  85.     cld
  86.     cmp    [ss:xormask],0
  87.     ja    @@1
  88.  
  89.     REPT    4
  90.     movsw
  91.     add    di,2000h-2
  92.     movsw
  93.     sub    di,2000h-78
  94.     ENDM
  95.     jmp    @@exit
  96. @@1:
  97.     REPT    4
  98.     lodsw
  99.     xor    ax,0ffffh
  100.     stosw
  101.     add    di,2000h-2
  102.     lodsw
  103.     xor    ax,0ffffh
  104.     stosw
  105.     sub    di,2000h-78
  106.     ENDM
  107. @@exit:
  108.     ret
  109. ENDP
  110.  
  111. ;====================================================
  112. ;
  113. ; Draw EGA chars
  114. ;
  115. ;====================================================
  116. PROC EGAcharout
  117. PUBLIC EGAcharout
  118. ARG    x:WORD,y:WORD,chr:BYTE,video:WORD
  119. USES si,di,ds,bp
  120.  
  121.     mov    dx,GCindex
  122.     mov    ax,GCmode
  123.     out    dx,ax
  124.  
  125.     mov    bx,[y]
  126.     shl    bx,1
  127.     shl    bx,1
  128.     shl    bx,1
  129.     add    bx,[yshift]
  130.     shl    bx,1
  131.  
  132.     cmp    [video],1
  133.     jne    @@0
  134.     mov    cx,39
  135.     mov    di,[EGA1lookup+bx]
  136.     jmp    @@1
  137. @@0:
  138.     mov    cx,79
  139.     mov    di,[EGA2lookup+bx]
  140. @@1:
  141.     add    di,[x]
  142.  
  143.     mov    ax,0a000h
  144.     mov    es,ax
  145.     mov    ds,ax
  146.  
  147.     mov    si,0f000h
  148.     mov    al,[chr]
  149.     xor    ah,ah
  150.     shl    ax,1
  151.     shl    ax,1
  152.     shl    ax,1
  153.     add    si,ax
  154.  
  155.     cld
  156.     cmp    [ss:xormask],0
  157.     ja    @@2
  158.  
  159.     mov    dx,GCindex
  160.     mov    ax,GCmode OR 100h
  161.     out    dx,ax
  162.     mov    dx,SCindex
  163.     mov    ax,SCmapmask OR 0f00h
  164.     out    dx,ax
  165.  
  166.     REPT    8
  167.     movsb
  168.     add    di,cx
  169.     ENDM
  170.     jmp    @@exit
  171.  
  172. @@2:
  173. ga    =    100h
  174. gb    =    0
  175.     mov    bp,si
  176.     mov    bx,di
  177.     REPT    4
  178.     mov    dx,SCindex
  179.     mov    ax,SCmapmask OR ga
  180.     out    dx,ax
  181.     mov    dx,GCindex
  182.     mov    ax,GCreadmap OR gb
  183.     out    dx,ax
  184.     REPT    8
  185.     lodsb
  186.     xor    al,0ffh
  187.     stosb
  188.     add    di,cx
  189.     ENDM
  190.     mov    di,bx
  191.     mov    si,bp
  192. ga    =    ga*2
  193. gb    =    gb+100h
  194.     ENDM
  195. @@exit:
  196.     mov    dx,GCindex
  197.     mov    ax,GCmode
  198.     out    dx,ax
  199.     ret
  200. ENDP
  201.  
  202. ;====================================================
  203. ;
  204. ; Draw VGA chars
  205. ;
  206. ;====================================================
  207. PROC VGAcharout
  208. PUBLIC VGAcharout
  209. ARG    x:WORD,y:WORD,chr:BYTE
  210. USES si,di,ds
  211.  
  212.     mov    bx,[y]
  213.     shl    bx,1
  214.     shl    bx,1
  215.     shl    bx,1
  216.     add    bx,[yshift]
  217.     shl    bx,1
  218.     mov    di,[VGAlookup+bx]
  219.  
  220.     mov    ax,[x]
  221.     shl    ax,1
  222.     shl    ax,1
  223.     shl    ax,1
  224.     add    di,ax
  225.  
  226.     mov     ah,[chr]
  227.     xor    al,al
  228.     shr    ax,1
  229.     shr    ax,1    ;[chr]*64!
  230.     mov    si,ax
  231.  
  232.     mov    ax,0a000h
  233.     mov    es,ax
  234.     mov    ds,[VGAfont]
  235.  
  236.     cmp    [ss:xormask],0
  237.     ja    @@1
  238.  
  239.     REPT    8
  240.     REPT    4
  241.     movsw
  242.     ENDM
  243.     add    di,320-8
  244.     ENDM
  245.     jmp    @@exit
  246. @@1:
  247.     REPT    8
  248.     REPT    4
  249.     lodsw
  250.     xor    ax,0ffffh
  251.     stosw
  252.     ENDM
  253.     add    di,320-8
  254.     ENDM
  255. @@exit:
  256.     ret
  257. ENDP
  258.  
  259. END
  260.